package com.li.controller;

import com.li.pojo.dto.ActicityPageDto;
import com.li.pojo.po.Activity;
import com.li.pojo.po.PageResult;
import com.li.pojo.po.Result;
import com.li.service.ActivityService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;

@RestController
@RequestMapping("/clues/activity")
@Slf4j
public class ActivityController {
    @Autowired
    ActivityService activityService;
    //活动分页
    @GetMapping("/list")
    public PageResult list(ActicityPageDto acticityPageDto){
        PageResult pageResult=activityService.list(acticityPageDto);
        log.info("params:{}",acticityPageDto);
        return pageResult;
    }
    //新增活动
    @PostMapping
    public Result addActivity(@RequestBody Activity activity){
        activityService.add(activity);
        return new Result(200,"操作成功","");
    }
    //获取活动管理详细信息
    @GetMapping("/{id}")
    public Result findDetailAct(@PathVariable Integer id){
        Activity activity=activityService.findDetailAct(id);
        return new Result(200,"查询成功",activity);
    }
    //修改活动
    @PutMapping
    public Result modifyAct(@RequestBody Activity activity){
        activityService.modifyAct(activity);
        return new Result(200,"操作成功","");
    }
    //删除活动
    @DeleteMapping("/{ids}")
    public Result delete(@PathVariable List<Integer> ids){
        activityService.deleteAct(ids);
        return new Result(200,"操作成功","");
    }
    //获取渠道下活动
    @GetMapping("/listselect/{channel}")
    public Result query(@PathVariable String channel){
        List<Activity> list=activityService.query(channel);
        return new Result(200,"操作成功",list);
    }


}
